package com.idata.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum CollaborativeCaseTypeEnum {

    ADMINISTRATIVE_CASE(1, "行政案件"),
    CRIMINAL_CASE(2, "刑事案件"),
    ;

    private final Integer code;
    private final String desc;

    private static final Map<Integer, CollaborativeCaseTypeEnum> VALUES_FOR_CODE = new HashMap<>();

    static {
        for (CollaborativeCaseTypeEnum collaborativeCaseTypeEnum : CollaborativeCaseTypeEnum.values()) {
            VALUES_FOR_CODE.put(collaborativeCaseTypeEnum.getCode(), collaborativeCaseTypeEnum);
        }
    }

    @Nullable
    public static CollaborativeCaseTypeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        return VALUES_FOR_CODE.get(code);
    }
}
